Function RenderBodyCollision(body:Byte Ptr)
	Local m:Float[16]
	NewtonBodyGetMatrix(body, m)
	NewtonCollisionForEachPolygonDo(NewtonBodyGetCollision(body),m, RenderDebugCollision,body)
End Function

Type TCallbackData
	Field Body:Byte Ptr
	Field mat:Float Ptr
	Field index:Int
End Type

Function ForceCallback(body:Byte Ptr , mat:Float , index:Int) 
	NewtonWorldCriticalSectionLock(NewtonBodyGetWorld(body))
	Local Data:TCallbackData = New TCallbackData
	Data.Body = Body
	Data.mat = Null
	Data.index = index
	Local T2:TBody = TBody(newtonBodyGetUserData_(body))
	Local Ixx:Float[1]
	Local Iyy:Float[1]
	Local Izz:Float[1]
	Local mass:Float[1]
	NewtonBodyGetMassMatrix (body , mass , Ixx , Iyy , Izz) ;
	Local force:Float[] = [T2.World.Gravity[0]* T2.World.irrMultiplier, mass[0]* T2.World.Gravity[1] * T2.World.irrMultiplier, T2.World.Gravity[2]* T2.World.irrMultiplier]
	NewtonBodySetForce (body , force) 
	NewtonWorldCriticalSectionUnLock(NewtonBodyGetWorld(body))
End Function

Function TransformCallback(body:Byte Ptr , mat:Float Ptr , index:Int) 
	NewtonWorldCriticalSectionLock(NewtonBodyGetWorld(body))
	Local T:TBody = TBody(newtonBodyGetUserData_(body) )
	T.Update(mat) 
	NewtonWorldCriticalSectionUnLock(NewtonBodyGetWorld(body))
End Function
